package com.learn.restful.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
public class MyRestController {

    @GetMapping("/student/{stuId}")
    public String queryStudent(@PathVariable("stuId") Integer studentId){
        return  "get 方式查询的学生id： " + studentId;
    }

    @PostMapping("/student/{name}/{age}")
    public String createStudent(@PathVariable("name") String name,
                                @PathVariable("age") Integer age){
        return "post 创建资源：" + name+", age: " + age;
    }

    @PutMapping("/student/{id}/{age}")
    public String updateStudent(@PathVariable("id") Integer id,
                                @PathVariable("age") Integer age){
        return "put 更新id：" + id +"的age为： " + age;
    }

    @DeleteMapping("/student/{id}")
    public String deleteStudent(@PathVariable("id") Integer id){
        return "delete 删除掉id为：" + id +"的学生";
    }

}
